package model;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

import bean.UserBean;

/**
 * Moral :
 * Created by 卖火柴的小女孩 on 2018/2/12.
 */

public class LoginModelImpl implements LoginModel {
    List<UserBean> userBeanList = new ArrayList<>(Arrays.asList(new UserBean("zhangsan", "123456")));

    @Override
    public void login(final String userName, String password, final LoginModel.LoginOnListener loginOnListener) {
        /**
         * 此处进行网络请求和回调 可将Result直接返回LoginPresenterImpl处理
         */
        UserBean userBean = new UserBean(userName, password);
        for (UserBean item : userBeanList) {
            if (item.toString().equals(userBean.toString())) {
                loginOnListener.onSuccess(item);
                return;
            }
        }
        loginOnListener.onFail("账号或密码错误");
    }
}
